<template>
	<view class="wrap">
		<stu-list :stuList="stuList" :currIndex="currIndex" @selCurrStu="selCurrStu"></stu-list>
	</view>
</template>

<script>
	import StuList from './components/StuList'
	export default {
		components:{
			StuList
		},
		data(){
			return{
				stuList:[],
				currIndex:-1,
				stuName:'',
				fromPage:''//recordPage->老师学习记录切换学生进来  myClsPage->我的班级进来 查看某个学生的测评列表
			}
		},
		onLoad(options){
			this.fromPage = options.fromPage;
			this.stuList = uni.getStorageSync('stuList');
			this.stuName = options.stuName;
			for(let i in this.stuList){
				if(this.stuList[i].realName == this.stuName){
					this.currIndex = Number(i);
				}
			}
			var title = options.currClsName + '学生列表';
			setTimeout(()=>{
				uni.setNavigationBarTitle({
					title
				})
			},100)
		},
		methods:{
			selCurrStu(index,item){
				if(this.fromPage == 'recordPage'){
					this.currIndex = index;
					let pages = getCurrentPages();
					let prevPage = pages[pages.length - 2];
					prevPage.$vm.stuName = item.realName;
					prevPage.$vm.stuId = item.userId;
					prevPage.$vm.stuAccount = item.account;
					uni.navigateBack({delta:1})
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.wrap{
		padding: 30rpx 30rpx 0;
	}
</style>